home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************
- * This file contains the bulk of the program. All of the dialog box
- * stuff is performed in this file.
- **********************************************************************/
-
- #include "Creator Changer.h"
- #include "Creator Changer.dialog.h"
- #include "GetFileIcon.h"
-
-
- /**********************************************************************
- * Function Open_DLOG(), this function is a general function for
- * opening all of the Dialog boxes in the program.
- **********************************************************************/
-
- void Open_DLOG(DialogPtr *the_dialog, short ID, OSType the_type, short DLOG_ID, short num, Ptr storage, AEDescList *the_files, long num_of_files)
- {
-
- short item_hit, the_item;
- Handle menu_handle;
- Rect the_rect;
- Boolean done_with_dialog;
- ModalFilterUPP My_Dialog_FilterUPP;
- GrafPtr old_port;
- File_Union temp;
-
- GetPort(&old_port);
- done_with_dialog=FALSE;
- *the_dialog=GetNewDialog(DLOG_ID, storage, IN_FRONT);
-
- Make_Pop_Up_Menu(ID, the_type, num);
- GetDItem(*the_dialog, POP_UP_MENU, &the_item, &menu_handle, &the_rect);
- (**(ControlHandle)menu_handle).contrlValue=0;
- Draw1Control((ControlHandle)menu_handle);
-
- ShowWindow(*the_dialog);
- if(!Multiple_Files && *the_dialog==Chng_Dialog)
- {
- Set_Type_Text(&F_Type, File_Info.fdType);
- Set_Type_Text(&C_Type, File_Info.fdCreator);
- }
-
- My_Dialog_FilterUPP=NewModalFilterProc(My_Dialog_Filter);
-
- while(!done_with_dialog)
- {
- ModalDialog(My_Dialog_FilterUPP, &item_hit);
- if(*the_dialog==Chng_Dialog) done_with_dialog=Change_Dialog_Switch(*the_dialog, item_hit, menu_handle, the_files, num_of_files);
- else if(*the_dialog==Edit_Dialog) done_with_dialog= Edit_Dialog_Switch(*the_dialog, item_hit, menu_handle);
- else if(*the_dialog==Auto_Dialog) done_with_dialog= Auto_Dialog_Switch(*the_dialog, item_hit, menu_handle);
- else done_with_dialog=TRUE;
- }
-
- CloseDialog(*the_dialog);
- SetPort(old_port);
-
- }
-
-
-
- /**********************************************************************
- * Function Change_Dialog_Switch(), this function decides where events
- * in the Chng_Dialog box should go.
- **********************************************************************/
-
- Boolean Change_Dialog_Switch(DialogPtr the_dialog, short item_hit, Handle menu_handle, AEDescList *the_files, long num_of_files)
- {
- switch(item_hit)
- {
- case CHNG_OK:
- return(Handle_OK_Change(the_dialog, CHNG_CREATOR, CHNG_FILE, the_files, num_of_files));
- break;
- case POP_UP_MENU:
- Handle_pt_Pop_Up_Menu(menu_handle, the_dialog, CHNG_CREATOR, CHNG_FILE, NO);
- break;
- case CHNG_CANCEL:
- return(TRUE);
- break;
- case CHNG_MKLK:
- Handle_Make_Like(the_dialog, CHNG_FILE, CHNG_CREATOR, NIL_PTR);
- break;
- case CHNG_CRNT_CREATOR:
- if(!Multiple_Files) Set_DLOG_Text_Item(the_dialog, CHNG_CREATOR, C_Type.TEXT);
- break;
- case CHNG_CRNT_TYPE:
- if(!Multiple_Files) Set_DLOG_Text_Item(the_dialog, CHNG_FILE, F_Type.TEXT);
- break;
- defualt:
- break;
- }
- return(FALSE);
- }
-
-
- /**********************************************************************
- * Function Edit_Dialog_Switch(), this function decides where events
- * in the Edit_Dialog box should go.
- **********************************************************************/
-
- Boolean Edit_Dialog_Switch(DialogPtr the_dialog, short item_hit, Handle menu_handle)
- {
- switch(item_hit)
- {
- case EDIT_CLOSE:
- return(TRUE);
- break;
- case EDIT_ADD:
- Handle_Add_Pref_Item(the_dialog, EDIT_CREATOR, EDIT_FILE, EDIT_DESCR);
- Draw1Control((ControlHandle)menu_handle);
- break;
- case EDIT_DELETE:
- Handle_Delete_Pref_Item();
- Draw1Control((ControlHandle)menu_handle);
- break;
- case POP_UP_MENU:
- Handle_pt_Pop_Up_Menu(menu_handle, the_dialog, EDIT_CREATOR, EDIT_FILE, EDIT_DESCR);
- break;
- case EDIT_GET_FILE:
- Handle_Make_Like(the_dialog, EDIT_FILE, EDIT_CREATOR, NIL_PTR);
- break;
- defualt:
- break;
- }
- return(FALSE);
- }
-
-
- /**********************************************************************
- * Function Auto_Dialog_Switch(), this function decides where events
- * in the Auto_Dialog box should go.
- **********************************************************************/
-
- Boolean Auto_Dialog_Switch(DialogPtr the_dialog, short item_hit, Handle menu_handle)
- {
-
- global_prefs **rsrc_handle;
-
- switch(item_hit)
- {
- case AUTO_ADD:
- Handle_Add_Auto_Item(the_dialog, AUTO_FRM_TYPE, AUTO_CREATOR, AUTO_FILE);
- break;
- case AUTO_CLOSE:
- return(TRUE);
- break;
- case AUTO_DELETE:
- Handle_Delete_Auto_Item();
- break;
- case POP_UP_MENU:
- Handle_ac_Pop_Up_Menu(menu_handle, the_dialog, AUTO_FRM_TYPE, AUTO_CREATOR, AUTO_FILE);
- break;
- case AUTO_DO:
- UseResFile(CreatorChangerPref);
- rsrc_handle=(global_prefs **)GetResource(PREF_GL, 128);
- (**rsrc_handle).AutoChange=Handle_Check_item(the_dialog, AUTO_DO);;
- ChangedResource((Handle)rsrc_handle);
- UpdateResFile(CreatorChangerPref);
- UseResFile(CreatorChangerApp);
- break;
- case AUTO_QUIT:
- UseResFile(CreatorChangerPref);
- rsrc_handle=(global_prefs **)GetResource(PREF_GL, 128);
- (**rsrc_handle).DragQuit=Handle_Check_item(the_dialog, AUTO_QUIT);;
- ChangedResource((Handle)rsrc_handle);
- UpdateResFile(CreatorChangerPref);
- UseResFile(CreatorChangerApp);
- break;
- case AUTO_GET_FILE:
- Handle_Make_Like(the_dialog, AUTO_FILE, AUTO_CREATOR, AUTO_FRM_TYPE);
- defualt:
- break;
- }
- return(FALSE);
- }
-
-
- /**********************************************************************
- * Function Handle_OK_Change(), this function calls the functions
- * which do the changing of the creator and file types.
- **********************************************************************/
-
- Boolean Handle_OK_Change(DialogPtr the_dialog, int creator, int file, AEDescList *the_files, long num_of_files)
- {
-
- int temp;
- int register i;
- AEKeyword key_word;
- DescType the_type;
- Size the_size;
-
- temp=Check_Data(the_dialog, file, NO)+Check_Data(the_dialog, creator, NO);
-
- if(temp<TYPE_LEN)
- {
- for(i=1;i<=num_of_files;i++)
- {
- if(Multiple_Files)
- {
- AEGetNthPtr(the_files, i, typeFSS, &key_word, &the_type, &The_File_Spec, sizeof(The_File_Spec), &the_size);
- FSpGetFInfo(&The_File_Spec, &File_Info);
- }
- Set_Long_Type(NIL_PTR, &File_Info.fdType, the_dialog, file);
- Set_Long_Type(NIL_PTR, &File_Info.fdCreator, the_dialog, creator);
- FSpSetFInfo(&The_File_Spec, &File_Info);
- }
- Force_Finder_Update(&The_File_Spec);
- if(Multiple_Files) AEDisposeDesc(the_files);
- return(GOOD);
- }
- else
- {
- Do_Error(Types_Error_1, EMPTY_STR, Types_Error_2, EMPTY_STR);
- return(BAD);
- }
- }
-
-
-
- /**********************************************************************
- * Function Set_Long_Type(), this function sets the file type of the
- * specified file. (converts a string in an edit field to an
- * unsigned decimal equivalent, and then returns it).
- **********************************************************************/
-
- void Set_Long_Type(Str4 in_string, OSType *out_long, DialogPtr the_dialog, int ID)
- {
-
- File_Union file_type;
- Handle item_handle;
- short item_type;
- Rect item_rect;
- int i;
-
- if(the_dialog!=NIL_PTR)
- {
- GetDItem(the_dialog, ID, &item_type, &item_handle, &item_rect);
- GetIText(item_handle, in_string);
- }
-
- for(i=0;i<=TYPE_LEN;i++) file_type.TEXT[i]=in_string[i+1];
-
- *out_long=file_type.LONG;
-
- }
-
-
-
- /**********************************************************************
- * Function Handle_Make_Like(), this function picks a file to use as
- * a template.
- **********************************************************************/
-
- void Handle_Make_Like(DialogPtr the_dialog, short file, short creator, short from_file)
- {
-
- File_Union f_type, c_type;
- FInfo ml_file_info;
- FSSpec ml_file_spec;
-
- if(Pick_File(&ml_file_spec, &ml_file_info, FALSE))
- {
- Set_Type_Text(&f_type, ml_file_info.fdType);
- Set_Type_Text(&c_type, ml_file_info.fdCreator);
-
- if(from_file) Set_DLOG_Text_Item(the_dialog, from_file, f_type.TEXT);
- Set_DLOG_Text_Item(the_dialog, file, f_type.TEXT);
- Set_DLOG_Text_Item(the_dialog, creator, c_type.TEXT);
-
- if(the_dialog==Edit_Dialog) PT_Item_To_Edit=0;
- }
-
- }
-
-
-
- /**********************************************************************
- * Function Set_Type_Text(), this function sets the text for the file
- * and creator types given an usigned decimal file / creator type.
- **********************************************************************/
-
- void Set_Type_Text(File_Union *the_type, OSType the_long_type)
- {
-
- File_Union temp;
- int i;
-
- (*the_type).TEXT[0]=TYPE_LEN;
- temp.LONG=the_long_type;
- for(i=0;i<=TYPE_LEN;i++) (*the_type).TEXT[i+1]=temp.TEXT[i];
-
- }
-
-
-
- /**********************************************************************
- * Function Handle_Add_Pref_Item(), this function actually does the adding
- * of the items to the preferences file.
- **********************************************************************/
-
- void Handle_Add_Pref_Item(DialogPtr the_dialog, int creator, int file, int description)
- {
-
- pref_types **rsrc_handle;
- Handle item_handle;
- short item_type;
- Rect item_rect;
- Str4 file_type, creator_type;
- Str32 description_type;
- int temp;
-
- temp=Check_Data(the_dialog, file, NO)+Check_Data(the_dialog, creator, NO)+Check_Data(the_dialog, description, YES);
-
- if(temp<TYPE_LEN)
- {
- UseResFile(CreatorChangerPref);
- rsrc_handle=(pref_types **)NewHandle(sizeof(pref_types));
-
- GetDItem(the_dialog, description, &item_type, &item_handle, &item_rect);
- GetIText(item_handle, description_type);
- GetDItem(the_dialog, creator, &item_type, &item_handle, &item_rect);
- GetIText(item_handle, creator_type);
- GetDItem(the_dialog, file, &item_type, &item_handle, &item_rect);
- GetIText(item_handle, file_type);
-
- p_Str_Copy(description_type, (**rsrc_handle).Description);
- p_Str_Copy(creator_type, (**rsrc_handle).CreatorType);
- p_Str_Copy(file_type, (**rsrc_handle).FileType);
-
- AddResource((Handle)rsrc_handle, PREF_PT, Num_pt==0 ? Strt_Rsrc : The_pt_Type[Num_pt]+1, description_type);
- ChangedResource((Handle)rsrc_handle);
- UpdateResFile(CreatorChangerPref);
- Num_pt=CountResources(PREF_PT);
- ReleaseResource((Handle)rsrc_handle);
- UseResFile(CreatorChangerApp);
- Make_Pop_Up_Menu(PREF_TYPES_ID, PREF_PT, Num_pt);
- PT_Item_To_Edit=0;
- }
- else if(temp<=TYPE_LEN+TYPE_LEN+1) Do_Error(Types_Error_1, EMPTY_STR, Types_Error_2, EMPTY_STR);
- else if(temp==DESC_LEN+2) Do_Error(Descr_Error, EMPTY_STR, EMPTY_STR, EMPTY_STR);
- else Do_Error(Types_Error_1, Descr_Error, EMPTY_STR, EMPTY_STR);
-
- }
-
-
-
- /**********************************************************************
- * Function Handle_Delete_Pref_Item(), this function actually does the
- * deleting of the item from the preferences file.
- **********************************************************************/
-
- void Handle_Delete_Pref_Item()
- {
-
- pref_types **rsrc_handle;
- short resource_number, i;
-
- if(PT_Item_To_Edit)
- {
- UseResFile(CreatorChangerPref);
- resource_number=The_pt_Type[PT_Item_To_Edit];
- rsrc_handle=(pref_types **)NewHandle(sizeof(pref_types));
- rsrc_handle=(pref_types **)GetResource(PREF_PT, resource_number);
- RmveResource((Handle)rsrc_handle);
- ReleaseResource((Handle)rsrc_handle);
- UpdateResFile(CreatorChangerPref);
-
- for(i=(resource_number+1);i<=The_pt_Type[Num_pt];i++)
- {
- rsrc_handle=(pref_types **)GetResource(PREF_PT, i);
- DetachResource((Handle)rsrc_handle);
- AddResource((Handle)rsrc_handle, PREF_PT, i-1, NIL_PTR);
- ChangedResource((Handle)rsrc_handle);
- ReleaseResource((Handle)rsrc_handle);
-
- rsrc_handle=(pref_types **)GetResource(PREF_PT, i);
- RmveResource((Handle)rsrc_handle);
- ChangedResource((Handle)rsrc_handle);
- ReleaseResource((Handle)rsrc_handle);
- }
-
- UpdateResFile(CreatorChangerPref);
- Num_pt=CountResources(PREF_PT);
- UseResFile(CreatorChangerApp);
- Make_Pop_Up_Menu(PREF_TYPES_ID, PREF_PT, Num_pt);
- PT_Item_To_Edit=0;
- }
- else Do_Error(Bad_Item_Error, EMPTY_STR, EMPTY_STR, EMPTY_STR);
-
- }
-
-
-
- /**********************************************************************
- * Function Handle_Add_Auto_Item(), this function actually does the adding
- * of the items to the preferences file.
- **********************************************************************/
-
- void Handle_Add_Auto_Item(DialogPtr the_dialog, int from_file_id, int to_creator_id, int to_file_id)
- {
-
- Handle item_handle;
- OSType long_from_file;
- short item_type;
- Rect item_rect;
- int temp;
- auto_chng **rsrc_handle;
- Str4 from_file, to_creator, to_file, types[100];
-
- temp=Check_Data(the_dialog, from_file_id, NO)+Check_Data(the_dialog, to_creator_id, NO)+Check_Data(the_dialog, to_file_id, NO);
-
- if(temp<TYPE_LEN)
- {
- Get_Types_From_Prefs(types);
- Set_Long_Type(NIL_PTR, &long_from_file, the_dialog, from_file_id);
- if(Check_File_Type(types, long_from_file))
- {
- ParamText(Bad_CF_Type_1, Bad_CF_Type_2, Bad_CF_Type_3, Bad_CF_Type_4);
- Alert(ERROR_ALERT_ID, NIL_PTR);
- }
- else
- {
- GetDItem(the_dialog, from_file_id, &item_type, &item_handle, &item_rect);
- GetIText(item_handle, from_file);
- GetDItem(the_dialog, to_creator_id, &item_type, &item_handle, &item_rect);
- GetIText(item_handle, to_creator);
- GetDItem(the_dialog, to_file_id, &item_type, &item_handle, &item_rect);
- GetIText(item_handle, to_file);
-
- rsrc_handle=(auto_chng **)NewHandle(sizeof(auto_chng));
- p_Str_Copy(from_file, (**rsrc_handle).FromFile);
- p_Str_Copy(to_creator, (**rsrc_handle).ToCreator);
- p_Str_Copy(to_file, (**rsrc_handle).ToFile);
- Make_ac_Name((**rsrc_handle).Name, from_file, to_creator, to_file);
-
- UseResFile(CreatorChangerPref);
- AddResource((Handle)rsrc_handle, PREF_AC, Num_ac==0 ? Strt_Rsrc : The_ac_Type[Num_ac]+1, (**rsrc_handle).Name);
- ChangedResource((Handle)rsrc_handle);
- UpdateResFile(CreatorChangerPref);
- Num_ac=CountResources(PREF_AC);
- UseResFile(CreatorChangerApp);
- ReleaseResource((Handle)rsrc_handle);
- }
- Make_Pop_Up_Menu(AUTO_CHANGE_ID, PREF_AC, Num_ac);
- AC_Item_To_Edit=0;
- }
- else Do_Error(Types_Error_1, EMPTY_STR, EMPTY_STR, EMPTY_STR);
-
- }
-
-
-
- /**********************************************************************
- * Function Make_ac_Name(), this function makes the name
- * which shows up in the pop-up menu for the auto change items.
- **********************************************************************/
-
- void Make_ac_Name(StringPtr name, StringPtr from_file, StringPtr to_creator, StringPtr to_file)
- {
-
- register int i;
-
- name[0]=16;
- for(i=1;i<=4;i++) name[i]=from_file[i];
- name[5]='-';
- name[6]='>';
- for(i=7;i<=10;i++) name[i]=to_creator[i-6];
- name[11]=',';
- name[12]=' ';
- for(i=13;i<=16;i++) name[i]=to_file[i-12];
-
- }
-
-
- /**********************************************************************
- * Function Handle_Delete_Auto_Item(), this function deletes items
- * from the auto change item list.
- **********************************************************************/
-
- void Handle_Delete_Auto_Item(void)
- {
-
- auto_chng **rsrc_handle;
- short resource_number, i;
-
- if(AC_Item_To_Edit)
- {
- UseResFile(CreatorChangerPref);
- resource_number=The_ac_Type[AC_Item_To_Edit];
-
- rsrc_handle=(auto_chng **)NewHandle(sizeof(auto_chng));
- rsrc_handle=(auto_chng **)GetResource(PREF_AC, resource_number);
- RmveResource((Handle)rsrc_handle);
- ReleaseResource((Handle)rsrc_handle);
- UpdateResFile(CreatorChangerPref);
-
- for(i=(resource_number+1);i<=The_ac_Type[Num_ac];i++)
- {
- rsrc_handle=(auto_chng **)GetResource(PREF_AC, i);
- DetachResource((Handle)rsrc_handle);
- AddResource((Handle)rsrc_handle, PREF_AC, i-1, NIL_PTR);
- ChangedResource((Handle)rsrc_handle);
- ReleaseResource((Handle)rsrc_handle);
-
- rsrc_handle=(auto_chng **)GetResource(PREF_AC, i);
- RmveResource((Handle)rsrc_handle);
- ChangedResource((Handle)rsrc_handle);
- ReleaseResource((Handle)rsrc_handle);
- }
-
- UpdateResFile(CreatorChangerPref);
- Num_ac=CountResources(PREF_AC);
- UseResFile(CreatorChangerApp);
- Make_Pop_Up_Menu(AUTO_CHANGE_ID, PREF_AC, Num_ac);
- AC_Item_To_Edit=0;
- }
- else Do_Error(Bad_Item_Error, EMPTY_STR, EMPTY_STR, EMPTY_STR);
-
- }
-
-
- /**********************************************************************
- * Function Handle_Check_item(), this function either checks or
- * unchecks a check box item.
- **********************************************************************/
-
- Boolean Handle_Check_item(DialogPtr the_dialog, short dialog_item)
- {
-
- short the_item;
- Handle the_handle;
- Rect the_rect;
- Boolean value;
-
- GetDItem(the_dialog, dialog_item, &the_item, &the_handle, &the_rect);
- value=GetCtlValue((ControlHandle)the_handle);
-
- if(value==TRUE)
- {
- SetCtlValue((ControlHandle)the_handle, FALSE);
- return(FALSE);
- }
- else if(value==FALSE)
- {
- SetCtlValue((ControlHandle)the_handle, TRUE);
- return(TRUE);
- }
-
- }
-
-
- /**********************************************************************
- * Function Draw_Default_Border(), this function draws the border
- * around the item sent to it, that is within the specified dialog box
- **********************************************************************/
-
- void Draw_Border(DialogPtr the_dialog, short the_item, short is_default)
- {
-
- Handle the_handle;
- short the_type;
- Rect the_rect;
- GrafPtr old_port;
- short diameter;
-
- GetPort(&old_port);
- SetPort(the_dialog);
-
- GetDItem(the_dialog, the_item, &the_type, &the_handle, &the_rect);
-
- if(is_default)
- {
- diameter=(the_rect.bottom-the_rect.top)/2+6;
- if(diameter<16) diameter=16;
- PenSize(3, 3);
- InsetRect(&the_rect, -4, -4);
- FrameRoundRect(&the_rect, diameter, diameter);
- }
- else
- {
- PenSize(1, 1);
- FrameRect(&the_rect);
- }
-
- SetPort(old_port);
-
- }
-
-
-
- /**********************************************************************
- * Function My_Dialog_Filter(), this function handels if there was a
- * particular key pressed in the dialog box, and if the dialog box was
- * moved at all.
- **********************************************************************/
-
- pascal Boolean My_Dialog_Filter(DialogPtr the_dialog, EventRecord *the_event, short *item_hit)
- {
-
- Boolean answer=FALSE;
-
- switch(the_event->what)
- {
- case updateEvt:
- {
- GrafPtr old_port;
-
- GetPort(&old_port);
- SetPort(the_dialog);
-
- BeginUpdate(the_dialog);
- UpdtDialog(the_dialog, the_dialog->visRgn);
- if(the_dialog==Chng_Dialog) Draw_Dialog(Chng_Dialog);
- else if(the_dialog==Edit_Dialog) Draw_Dialog(Edit_Dialog);
- else if(the_dialog==Auto_Dialog) Draw_Dialog(Auto_Dialog);
- EndUpdate(the_dialog);
-
- SetPort(old_port);
- answer=TRUE;
- }
- break;
- case mouseDown:
- {
- WindowPtr the_window;
- RgnHandle the_gray_rgn;
- short the_part;
- static Point where;
-
- where=the_event->where;
-
- the_part=FindWindow(where, &the_window);
- if((the_part==inDrag) && (the_window==the_dialog))
- {
- the_gray_rgn=GetGrayRgn();
- DragWindow(the_window, the_event->where, &((**the_gray_rgn).rgnBBox));
- answer=TRUE;
- }
- else GlobalToLocal(&where);
- }
- break;
- case keyDown:
- {
- static char key_pressed;
-
- key_pressed=the_event->message & charCodeMask;
-
- if(!(the_event->modifiers & cmdKey))
- {
- PT_Item_To_Edit=0;
- switch(key_pressed)
- {
- case Escape_Key:
- if(the_dialog==Chng_Dialog) answer=Handle_Key_Pressed(the_dialog, CHNG_CANCEL, item_hit);
- else if(the_dialog==Edit_Dialog) answer=Handle_Key_Pressed(the_dialog, EDIT_CLOSE, item_hit);
- else if(the_dialog==Auto_Dialog) answer=Handle_Key_Pressed(the_dialog, AUTO_CLOSE, item_hit);
- break;
- case Return_Key:
- case Enter_Key:
- if(the_dialog==Chng_Dialog) answer=Handle_Key_Pressed(the_dialog, CHNG_OK, item_hit);
- else if(the_dialog==Edit_Dialog) answer=Handle_Key_Pressed(the_dialog, EDIT_CLOSE, item_hit);
- else if(the_dialog==Auto_Dialog) answer=Handle_Key_Pressed(the_dialog, AUTO_CLOSE, item_hit);
- break;
- }
- }
- else
- {
- if(the_dialog==Chng_Dialog)
- switch(key_pressed)
- {
- case 'M':
- case 'm':
- answer=Handle_Key_Pressed(the_dialog, CHNG_MKLK, item_hit);
- break;
- case 'C':
- case 'c':
- answer=Handle_Key_Pressed(the_dialog, CHNG_CANCEL, item_hit);
- break;
- }
- else if(the_dialog==Edit_Dialog)
- switch(key_pressed)
- {
- case 'D':
- case 'd':
- answer=Handle_Key_Pressed(the_dialog, EDIT_DELETE, item_hit);
- break;
- case 'A':
- case 'a':
- answer=Handle_Key_Pressed(the_dialog, EDIT_ADD, item_hit);
- break;
- case 'G':
- case 'g':
- answer=Handle_Key_Pressed(the_dialog, EDIT_GET_FILE, item_hit);
- break;
- }
- else if(the_dialog==Auto_Dialog)
- switch(key_pressed)
- {
- case 'D':
- case 'd':
- answer=Handle_Key_Pressed(the_dialog, AUTO_DELETE, item_hit);
- break;
- case 'A':
- case 'a':
- answer=Handle_Key_Pressed(the_dialog, AUTO_ADD, item_hit);
- break;
- case 'C':
- case 'c':
- answer=Handle_Key_Pressed(the_dialog, AUTO_DO, item_hit);
- break;
- case 'Q':
- case 'q':
- answer=Handle_Key_Pressed(the_dialog, AUTO_QUIT, item_hit);
- break;
- case 'G':
- case 'g':
- answer=Handle_Key_Pressed(the_dialog, AUTO_GET_FILE, item_hit);
- break;
- }
- }
- }
- break;
- }
- return(answer);
- }
-
-
-
- /**********************************************************************
- * Function Handle_Key_Pressed(), this function handels what happens
- * if a key is pressed.
- **********************************************************************/
-
- int Handle_Key_Pressed(DialogPtr the_dialog, int the_item, short *item_hit)
- {
-
- short item_type, item_value;
- Handle item_handle;
- Rect item_rect;
- long delay;
-
- GetDItem(the_dialog, the_item, &item_type, &item_handle, &item_rect);
- HiliteControl((ControlHandle)item_handle, 1);
- Delay(DELAY, &delay);
- HiliteControl((ControlHandle)item_handle, 0);
- *item_hit=the_item;
- return(TRUE);
-
- }
-
-
-
- /**********************************************************************
- * Function Check_Data(), this function checks the type entered
- * by the user. If there are more than 4 charachters than there is
- * an error, and if there is no data entered in there is an error.
- **********************************************************************/
-
- int Check_Data(DialogPtr the_dialog, int ID, short is_desc)
- {
-
- Str255 the_error;
- Str32 item_text;
- Handle item_handle;
- short item_type;
- Rect item_rect;
- int len;
- short the_type_len;
-
- GetDItem(the_dialog, ID, &item_type, &item_handle, &item_rect);
- GetIText(item_handle, item_text);
-
- len=item_text[0];
- if(is_desc) the_type_len=DESC_LEN;
- else the_type_len=TYPE_LEN;
- if(len!=the_type_len && the_type_len==TYPE_LEN) return(TYPE_LEN);
- else if((len>the_type_len && the_type_len==DESC_LEN) || len==0) return(DESC_LEN);
- else return(GOOD);
-
- }
-
-
-
- /**********************************************************************
- * Function Set_DLOG_Text_Item(), this function sets text boxes in the
- * selected dialog to the text which is sent to it.
- **********************************************************************/
-
- void Set_DLOG_Text_Item(DialogPtr the_dialog, short ID, StringPtr the_text)
- {
-
- Handle the_handle;
- Rect the_rect;
- short item_type;
-
- GetDItem(the_dialog, ID, &item_type, &the_handle, &the_rect);
- SetIText(the_handle, the_text);
-
- }
-
-
-
- /**********************************************************************
- * Function Draw_Dialog(), this function draws the objects in the
- * main dialog box.
- **********************************************************************/
-
- void Draw_Dialog(DialogPtr the_dialog)
- {
-
- Handle the_handle;
- Rect the_rect;
- short item_type;
-
- if(the_dialog==Chng_Dialog)
- {
- TextFont(systemFont);
- TextSize(12);
- TextFace(0);
-
- if(!Multiple_Files)
- {
- GetDItem(Chng_Dialog, CHNG_ICON, &item_type, &the_handle, &the_rect);
- PlotIconSuite(&the_rect, 0, 0, The_Icons);
-
- Draw_Border(Chng_Dialog, CHNG_CRNT_CREATOR, NO);
- GetDItem(Chng_Dialog, CHNG_CRNT_CREATOR, &item_type, &the_handle, &the_rect);
- MoveTo(the_rect.left+4, the_rect.bottom-7);
- DrawString(C_Type.TEXT);
-
- Draw_Border(Chng_Dialog, CHNG_CRNT_TYPE, NO);
- GetDItem(Chng_Dialog, CHNG_CRNT_TYPE, &item_type, &the_handle, &the_rect);
- MoveTo(the_rect.left+4, the_rect.bottom-7);
- DrawString(F_Type.TEXT);
- }
-
- Draw_Border(Chng_Dialog, CHNG_OK, YES);
- }
- else if(the_dialog==Edit_Dialog)
- {
- Draw_Border(Edit_Dialog, EDIT_CLOSE, YES);
- }
- else if(the_dialog==Auto_Dialog)
- {
- GetDItem(Auto_Dialog, AUTO_DO, &item_type, &the_handle, &the_rect);
- SetCtlValue((ControlHandle)the_handle, (**Global).AutoChange);
- GetDItem(Auto_Dialog, AUTO_QUIT, &item_type, &the_handle, &the_rect);
- SetCtlValue((ControlHandle)the_handle, (**Global).DragQuit);
-
- Draw_Border(Auto_Dialog, AUTO_CLOSE, YES);
- }
-
- }
-